| Conditions | 1 |
| Paths | 1 |
| Total Lines | 113 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | /** |
||
| 11 | describe("Get cards with different values", function() { |
||
| 12 | describe("Get card with value 0", function() { |
||
| 13 | it("should be card ♣A", function() { |
||
| 14 | let card = new Card(); |
||
| 15 | let res = card.getCard(0); |
||
| 16 | |||
| 17 | assert.equal(res, "♣A"); |
||
| 18 | }); |
||
| 19 | |||
| 20 | it("should have rank 14", function() { |
||
| 21 | let card = new Card(); |
||
| 22 | let res = card.getRank(0); |
||
| 23 | |||
| 24 | assert.equal(res, 14); |
||
| 25 | }); |
||
| 26 | }); |
||
| 27 | |||
| 28 | describe("Get card with value 1", function() { |
||
| 29 | it("should be card ♣2", function() { |
||
| 30 | let card = new Card(); |
||
| 31 | let res = card.getCard(1); |
||
| 32 | |||
| 33 | assert.equal(res, "♣2"); |
||
| 34 | }); |
||
| 35 | |||
| 36 | it("should have rank 2", function() { |
||
| 37 | let card = new Card(); |
||
| 38 | let res = card.getRank(1); |
||
| 39 | |||
| 40 | assert.equal(res, 2); |
||
| 41 | }); |
||
| 42 | }); |
||
| 43 | |||
| 44 | describe("Get card with value 13", function() { |
||
| 45 | it("should be card ♦A", function() { |
||
| 46 | let card = new Card(); |
||
| 47 | let res = card.getCard(13); |
||
| 48 | |||
| 49 | assert.equal(res, "♦A"); |
||
| 50 | }); |
||
| 51 | |||
| 52 | it("should have rank 14", function() { |
||
| 53 | let card = new Card(); |
||
| 54 | let res = card.getRank(13); |
||
| 55 | |||
| 56 | assert.equal(res, 14); |
||
| 57 | }); |
||
| 58 | }); |
||
| 59 | |||
| 60 | describe("Get card with value 26", function() { |
||
| 61 | it("should be card ♠A", function() { |
||
| 62 | let card = new Card(); |
||
| 63 | let res = card.getCard(26); |
||
| 64 | |||
| 65 | assert.equal(res, "♠A"); |
||
| 66 | }); |
||
| 67 | |||
| 68 | it("should have rank 14", function() { |
||
| 69 | let card = new Card(); |
||
| 70 | let res = card.getRank(26); |
||
| 71 | |||
| 72 | assert.equal(res, 14); |
||
| 73 | }); |
||
| 74 | }); |
||
| 75 | |||
| 76 | describe("Get card with value 39", function() { |
||
| 77 | it("should be card ♥A", function() { |
||
| 78 | let card = new Card(); |
||
| 79 | let res = card.getCard(39); |
||
| 80 | |||
| 81 | assert.equal(res, "♥A"); |
||
| 82 | }); |
||
| 83 | |||
| 84 | it("should have rank 14", function() { |
||
| 85 | let card = new Card(); |
||
| 86 | let res = card.getRank(39); |
||
| 87 | |||
| 88 | assert.equal(res, 14); |
||
| 89 | }); |
||
| 90 | }); |
||
| 91 | |||
| 92 | describe("Get card with value 51", function() { |
||
| 93 | it("should be card ♥K", function() { |
||
| 94 | let card = new Card(); |
||
| 95 | let res = card.getCard(51); |
||
| 96 | |||
| 97 | assert.equal(res, "♥K"); |
||
| 98 | }); |
||
| 99 | |||
| 100 | it("should have rank 13", function() { |
||
| 101 | let card = new Card(); |
||
| 102 | let res = card.getRank(51); |
||
| 103 | |||
| 104 | assert.equal(res, 13); |
||
| 105 | }); |
||
| 106 | }); |
||
| 107 | |||
| 108 | describe("Get card with value 52", function() { |
||
| 109 | it("should be undefined", function() { |
||
| 110 | let card = new Card(); |
||
| 111 | let res = card.getCard(52); |
||
| 112 | |||
| 113 | assert.equal(res, undefined); |
||
| 114 | }); |
||
| 115 | |||
| 116 | it("should have rank undefined", function() { |
||
| 117 | let card = new Card(); |
||
| 118 | let res = card.getRank(52); |
||
| 119 | |||
| 120 | assert.equal(res, undefined); |
||
| 121 | }); |
||
| 122 | }); |
||
| 123 | }); |
||
| 124 |